import qs from 'qs'
import request from '@/utils/request'
export function getNoGroupList(params,type) {
    return request({
        url: `/pass/api/${type}/access/device/no/group/list`,
        method: 'get',
        params
    })
}

export function getDeviceList(params,type) {
    return request({
        url: `/pass/api/${type}/access/device/list`,
        method: 'get',
        params
    })
}

export function groupAdd(data,type) {
    
    return request({
        url: `/pass/api/${type}/access/group/add`,
        method: 'post',
        data:qs.stringify(data)
    })
}

export function groupList(params,type) {
    return request({
        url: `/pass/api/${type}/access/group/list`,
        method: 'get',
        params
    })
}

export function groupDelete(params,type) {
    return request({
        url: `/pass/api/${type}/access/group/delete`,
        method: 'delete',
        params
    })
}

export function deviceDeleteGroup(params,type) {
    let query = '?'
    params.indexCodes.forEach(item => {
        query+='indexCodes='+item+'&'
    })
    return request({
        url: `/pass/api/${type}/access/device/delete/group`+query,
        method: 'delete',
       
    })
}

export function deviceAssignGroup(data,type) {
    let query = '?'
    data.indexCodes.forEach(item => {
        query+='indexCodes='+item+'&'
    })
    return request({
        url: `/pass/api/${type}/access/device/assign/group`+query,
        method: 'post',
        data: qs.stringify({ groupCode: data.groupCode,inAndOutType:data.inAndOutType}),
       
    })
}

export function groupUpdate(params,type) {
    return request({
        url: `/pass/api/${type}/access/group/update`,
        method: 'put',
        params
    })
}